#translating the answers:
#VAR ------- INDONESIAN ----------- ENGLISH

#V_15 ------ Tidak pernah --------- Have not done so
#V_15 ------ Ya, pernah ----------- Yes, have done so
#V_15 ------ TT/TJ ---------------- DK/NA


#V_16-20 --- Sangat setuju -------- Strongly agree
#V_16-20 --- Setuju --------------- Agree
#V_16-20 --- Tidak setuju --------- Disagree
#V_16-20 --- Sangat tidak setuju -- Strongly disagree
#V_16-20 --- TT/TJ ---------------- DK/NA

#V_21 ------ Tidak akan ----------- Will not do so
#V_21 ------ Ya, akan ------------- Yes, will do so
#V_21 ------ TT/TJ ---------------- DK/NA

#V_53 ------ Joko Widodo - Ma'ruf Amin ------------------- Joko Widodo - Ma'ruf Amin
#V_53 ------ Prabowo Subianto - Sandiaga Uno ------------- Prabowo Subianto - Sandiaga Uno
#V_53 ------ Rahasia/tidak jawab ------------------------- Secret/did not answer
#V_53 ------ Tidak ikut memilih -------------------------- Did not vote

english_df =
  survey_df %>%
  mutate(V_15 = case_when(
           V_15 == "Tidak pernah" ~ "No, have not done so",
           V_15 == "Ya, pernah" ~ "Yes, have done so",
           V_15 == "TT/TJ" ~ "DK/NA",
              TRUE ~ NA_character_
            )) %>%
  mutate_at(.vars = vars(V_16,V_17, V_18, V_19, V_20), 
            .funs = funs(. = case_when(
              . == "Sangat setuju" ~ "Strongly agree",
              . == "Setuju" ~ "Agree",
              . == "Tidak setuju" ~ "Disagree",
              . == "Sangat tidak setuju" ~ "Strongly disagree",
              . == "TT/TJ" ~ "DK/NA",
              TRUE ~ NA_character_
            ))) %>%
  mutate(V_21 = case_when(
             V_21 == "Tidak akan" ~ "No, will not do so",
             V_21 == "Ya akan" ~ "Yes, will do so",
             V_21 == "TT/TJ" ~ "DK/NA",
              TRUE ~ NA_character_
            )) %>%
  mutate(V_53 = case_when(
           V_53 == "Joko Widodo - Ma'ruf Amin" ~ "Joko Widodo - Ma'ruf Amin",
           V_53 == "Prabowo Subianto - Sandiaga Uno" ~ "Prabowo Subianto - Sandiaga Uno",
           V_53 == "Rahasia/tidak jawab" ~ "Secret/did not answer",
           V_53 == "Tidak ikut memilih" ~ "Did not vote",
              TRUE ~ NA_character_
            )) %>%
  dplyr::select(
    V_15, V_16 = V_16_., V_17 = V_17_., V_18 = V_18_., V_19 = V_19_., V_20 = V_20_., V_21, V_53, 
    religion, age, ethnicity, income, gender, prov_code
  )

write.csv(english_df, "./data/analysis_data_ENGLISH.csv")

rm(english_df)

